<template>
    <div class="app-container">
      <el-row :gutter="20">
        <el-col :span="24" :xs="24">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="平台名称" prop="platformName">
              <el-input
                v-model="queryParams.platformName"
                placeholder="请输入平台名称"
                clearable
                style="width: 240px"
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="地区" prop="area">
              <el-select
                v-model="queryParams.area"
                placeholder="地区"
                clearable
                style="width: 240px"
              >
                <el-option
                  v-for="dict in areaList"
                  :key="dict"
                  :label="dict"
                  :value="dict"
                />
              </el-select>
            </el-form-item>

            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
  
          <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
            <!-- <el-table-column type="selection" width="50" align="center" /> -->
            <el-table-column label="序号" type="index" width="50" />
            <el-table-column label="平台名称" align="center" prop="platformName" width="120" />
            <el-table-column label="地区" align="center" prop="area" width="120" />
            <el-table-column label="注册资本" align="center" prop="registeredCapital" width="120" />
            <!-- <el-table-column label="成立日期" align="center" prop="establishmentDate" width="120" /> -->
            <el-table-column label="营业执照" align="center" prop="businessLicenseNumber" width="200" />
            <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                
                <el-button size="mini" type="text" icon="el-icon-view">
                  <router-link :to="{ name: 'PlatformDetail', params: { id: scope.row.id } }">查看详情</router-link>
                </el-button>
                <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button> -->
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="total > 0" :total="total" :page.sync="queryParams.current" :limit.sync="queryParams.size"
            @pagination="getList" />
        </el-col>
      </el-row>
  
    </div>
  </template>
  
  <script>
  import { list, remove, detail, save, update } from "@/api/platform";
  export default {
    name: "platformList",
    // 组件
    components: {},
    // 数据
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 用户表格数据
        list: [],
        // 总条数
        total: 0,
        // 弹出层标题
        title: "",
        // 查询参数
        queryParams: {
          current: 1,
          size: 10,
        },
        // 表单参数
        form: {
          platformOperation: {}
        },
        // 是否显示弹出层
        open: false,
        // 搜索
        showSearch: true,
        areaList:[
          '北京',
          '上海',
          '广州',
          '深圳',
          '天津'
        ]
      };
    },
    // 监听
    watch: {},
    // 构造函数
    created() {
      this.getList();
    },
    // 函数方法
    methods: {
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map((item) => item.id);
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
      /** 查询列表 */
      getList() {
        this.loading = true;
        console.log('getList', this.queryParams)
        list(this.queryParams).then((response) => {
          // 后端返回
          console.log("list", response);
  
          const data = response.data;
          this.list = data.records;
          this.total = data.total;
          this.loading = false;
        });
      },
      handleQuery() {
        this.queryParams.current = 1;
        this.getList();
      },
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },

      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
  
      // 表单重置
      reset() {
        this.form = {
          platformOperation: {}
        };
        this.resetForm("form");
      },
      handleDetail(row) {

      }

  
    },
  };
  </script>
  
  <style scoped lang="scss"></style>
  